﻿<UserControl x:Class="UserAccountModule.Views.EditAccountView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:prism="http://www.codeplex.com/prism"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:inf_int="clr-namespace:Infrastructure.InteractionRequests;assembly=Infrastructure"
             xmlns:helper="clr-namespace:Infrastructure.Helpers;assembly=Infrastructure"
             xmlns:local="clr-namespace:UserAccountModule.Views"
             mc:Ignorable="d" 
             d:DesignHeight="720" d:DesignWidth="900" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Infrastructure;component/Themes/CommonTemplates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <helper:SuccessConverter x:Key="SuccessConverter" />
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <StackPanel>
            <TextBlock Margin="40,10,0,0" Text="Quản lý tài khoản cá nhân" 
                       FontWeight="Bold" Foreground="#FF7A7A7A" HorizontalAlignment="Left"  FontFamily="Segoe UI" FontSize="16" />
            <Rectangle Fill="#FFD6D6D6" Height="1" Margin="0,10 0,15" />
        </StackPanel>
<TextBlock Foreground="Red" Text="{Binding ElementName=dt,Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
        <StackPanel Grid.Row="1" HorizontalAlignment="Center"
					Margin="10">
            <StackPanel Orientation="Horizontal" Margin="5" VerticalAlignment="Center">
                <telerik:RadButton Width="38" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
                                   Command="{Binding SaveCommand}">
                    <telerik:RadButton.Content>
                        <Image Source="/Infrastructure;component/Images/MiniIcon/save_as.png" Height="14" Width="14"/>
                    </telerik:RadButton.Content>
                </telerik:RadButton>
                <TextBlock Text="Lưu thông tin" Foreground="#FF060606" FontSize="12" Margin="40 3 14 3" />
            </StackPanel>
        </StackPanel>

        <Grid Grid.Row="2" HorizontalAlignment="Center" DataContext="{Binding User, Mode=TwoWay}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <TextBlock Text="Tên người dùng:" Grid.Row="0"  Style="{StaticResource TextBlockStyle}"/>
            <TextBox Name="dt"  Grid.Column="1" Grid.Row="0" Text="{Binding Path=TenNguoiDung,Mode=TwoWay}" />
            <TextBlock Text="Giới tính:" Grid.Row="1"  Style="{StaticResource TextBlockStyle}"/>
            <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" Margin="0 0 0 15" HorizontalAlignment="Center">
                <telerik:RadRadioButton Width="60" Margin="0 0 15 0"
 IsChecked="{Binding Path=GioiTinh, Mode=TwoWay, Converter={StaticResource SuccessConverter}, ConverterParameter=true}"
						HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Nam" />
                <telerik:RadRadioButton Width="60" IsChecked="{Binding Path=GioiTinh, Mode=TwoWay, Converter={StaticResource SuccessConverter}, ConverterParameter=false}"
						HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Nữ" />
            </StackPanel>

            <TextBlock Text="Điện thoại:" Grid.Row="2"  Style="{StaticResource TextBlockStyle}"/>
            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=DienThoai,Mode=TwoWay}"/>
            <TextBlock Text="Email:" Grid.Row="3"  Style="{StaticResource TextBlockStyle}"/>
            <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=Email,Mode=TwoWay}" />
        </Grid>

        <Grid Grid.Row="3"  HorizontalAlignment="Center" Margin="0,15,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock Text="Mật khẩu cũ:" Grid.Row="0"  Style="{StaticResource TextBlockStyle}"/>
            <PasswordBox Grid.Column="1" Grid.Row="0" Margin="0,0,0,15" Width="150" helper:PasswordHelper.Password="{Binding Password, Mode=TwoWay}" />
            <TextBlock Text="Mật khẩu mới:" Grid.Row="1"  Style="{StaticResource TextBlockStyle}"/>
            <PasswordBox Grid.Column="1" Grid.Row="1" Margin="0,0,0,15" helper:PasswordHelper.Password="{Binding NewPassword, Mode=TwoWay}" />
            <TextBlock Text="Xác nhận mật khẩu mới:" Grid.Row="2"  Style="{StaticResource TextBlockStyle}"/>
            <PasswordBox Grid.Column="1" Grid.Row="2" Margin="0,0,0,15" helper:PasswordHelper.Password="{Binding ReNewPassword, Mode=TwoWay}" />
            <StackPanel Orientation="Horizontal" Margin="5" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Center">
                <telerik:RadButton Width="38"
                                   Command="{Binding ChangePasswordCommand}">
                    <telerik:RadButton.Content>
                        <Image Source="/Infrastructure;component/Images/MiniIcon/save_as.png" Height="14" Width="14"/>
                    </telerik:RadButton.Content>
                </telerik:RadButton>
                <TextBlock Text="Đổi mật khẩu" Foreground="#FF060606" FontSize="12" Margin="40 3 14 3" />
            </StackPanel>
        </Grid>
        <ContentPresenter 
      Content="{Binding ElementName=dt, Path=(Validation.Errors).CurrentItem}"
      HorizontalAlignment="Left"
      >
            <ContentPresenter.ContentTemplate>
                <DataTemplate>
                    <TextBlock
            Foreground="Red"
            FontStyle="Italic"
            Text="{Binding Path=ErrorContent}"
            />
                </DataTemplate>
            </ContentPresenter.ContentTemplate>
        </ContentPresenter>
    </Grid>
</UserControl>
